package club.emergency.wechat.persistence.authorization;

import club.emergency.wechat.model.authorization.AuthorizationHasRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author jifujun
 * @since 2019-03-19
 */
public interface AuthorizationHasRoleMapper extends BaseMapper<AuthorizationHasRole> {

    /**
     * 根据角色id删除中间表中数据
     *
     * @param id 角色id
     */
    @Delete("delete from authorization_has_role where role_id = #{id}")
    void removeByRoleId(@Param("id") Long id);

    /**
     * 根据角色id查询权限数据列表
     *
     * @param rollId 角色id
     * @return 权限数据列表
     */
    @Select("select authorization_id from authorization_has_role where role_id = #{id}")
    List<Long> selectAuthorizationIdListByRoleId(@Param("id") Long rollId);
}
